package com.niit.onlinemusicserver34.controller;

import com.niit.onlinemusicserver34.common.R;
import com.niit.onlinemusicserver34.model.request.CommentRequest;
import com.niit.onlinemusicserver34.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    // 提交评论
    @PostMapping("/add")
    public R addComment(@RequestBody CommentRequest addCommentRequest) {
        return commentService.addComment(addCommentRequest);
    }

    // 删除评论
    @GetMapping("/delete")
    public R deleteComment(@RequestParam Integer id) {
        return commentService.deleteComment(id);
    }

    // 点赞
    @PostMapping("/like")
    public R commentOfLike(@RequestBody CommentRequest upCommentRequest) {
        return commentService.updateCommentMsg(upCommentRequest);
    }
    //根据歌单id获取评论列表
    @GetMapping("/songList/{songListId}") // 路径参数
    public R commentListOfSongList(@PathVariable("songListId") Integer songListId) {
        return  commentService.getCommentListBySongListId(songListId);
    }

    //根据歌曲id获取评论列表
    @GetMapping("/song/detail") // 路径参数
    public R commentListOfSong(Integer songId) {
        return  commentService.getCommentListBySongListId(songId);
    }
}